Interactive maps from Xeno-Canto recording localities in xc_maps()

The function xc_maps() from the R package warbleR let users visualize the geographic spread of recordings from Xeno-Canto downloaded through the quer_xc() function. However, the graphs are static, which becomes a bit painful when looking at many recordings. Fortunately the R package leaflet allows to create interactive maps in which users can zoom in at specific areas, check observation medatada and link observations to their Xeno-Canto webpage. This capability is now available in xc_maps().

Here are a couple of examples on how to create these maps using xc_maps(). First we must install the latest warbleR developmental version from github (you need the R package devtools to do this) and also the package leaflet:

#Install warbleR
install.packages("warbleR")

#load package library(warbleR)

#install leaflet install.packages("leaflet")

A single species

This is an example with data from a single species. The argument ‘leaflet.map’ should be set to ‘TRUE’:

X <- querxc("Phaethornis longirostris", download = FALSE, pb = FALSE, parallel = 3)

#create leaflet map xcmaps(X, leaflet.map = TRUE)

Note that markers are color-labeled to indicate subspecies (white means subspecies was not determined).

 

If you click on the markers a small window pops up with recording metadata and links to the recording webpage (top) and to the recording itself (“listen”, bottom):

Several species

We can also look at recording localities from several species. In this case marker colors indicate different species, The map below shows all Xeno-Canto recordings for the genus Phaethornis (hermit hummingbirds):

X <- querxc("Phaethornis", download = FALSE, pb = FALSE, parallel = 3)

#create leaflet map xcmaps(X, leaflet.map = TRUE)

Clustering localities

In cases like this in which there are many recordings we can use the argument ‘leaflet.cluster’ to cluster recordings from near by localities in a single marker:

#create leaflet map clustering localities
xcmaps(X, leaflet.map = TRUE, leaflet.cluster = TRUE)

Markers for individual recordings are shown when zooming in.

These are cool maps, although they show pretty much the same info than those in Xeno-Canto. However, we could combine more complex queries (or data subsetting) with interacitve maps. This generates visualizations that are not possible using only Xeno-Canto maps. For instance, the following code shows the location of all recordings made in the Americas in 2020 (as of today 15-March-2020):

recs.2020 <- querxc(qword = 'area:"america" year:2020', 
                    download = FALSE, pb = FALSE)

xcmaps(recs.2020, leaflet.map = TRUE)

Same thing but with clusters:

xcmaps(recs.2020, leaflet.map = TRUE, leaflet.cluster = TRUE)

Or a subset showing those recordings made in Brazil only:

bra.2020 <- recs.2020[recs.2020$Country == "Brazil", ]

xcmaps(bra.2020, leaflet.map = TRUE, leaflet.cluster = TRUE)


Session information

## R version 3.6.1 (2019-07-05)
## Platform: x86_64-pc-linux-gnu (64-bit)
## Running under: Ubuntu 18.04.3 LTS
## 
## Matrix products: default
## BLAS:   /usr/lib/x86_64-linux-gnu/atlas/libblas.so.3.10.3
## LAPACK: /usr/lib/x86_64-linux-gnu/atlas/liblapack.so.3.10.3
## 
## locale:
##  [1] LC_CTYPE=es_ES.UTF-8       LC_NUMERIC=C              
##  [3] LC_TIME=es_CR.UTF-8        LC_COLLATE=es_ES.UTF-8    
##  [5] LC_MONETARY=es_CR.UTF-8    LC_MESSAGES=es_ES.UTF-8   
##  [7] LC_PAPER=es_CR.UTF-8       LC_NAME=C                 
##  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
## [11] LC_MEASUREMENT=es_CR.UTF-8 LC_IDENTIFICATION=C       
## 
## attached base packages:
## [1] stats     graphics  grDevices utils     datasets  methods   base     
## 
## other attached packages:
## [1] leaflet_2.0.3      warbleR_1.1.23     NatureSounds_1.0.2 knitr_1.28        
## [5] seewave_2.1.5      tuneR_1.3.3       
## 
## loaded via a namespace (and not attached):
##  [1] Rcpp_1.0.3        magrittr_1.5      maps_3.3.0        MASS_7.3-51.4    
##  [5] xtable_1.8-4      R6_2.4.1          rjson_0.2.20      rlang_0.4.1      
##  [9] fastmap_1.0.1     pbapply_1.4-2     stringr_1.4.0     tools_3.6.1      
## [13] parallel_3.6.1    xfun_0.12         dtw_1.21-3        htmltools_0.4.0  
## [17] crosstalk_1.0.0   yaml_2.2.1        digest_0.6.22     shiny_1.4.0      
## [21] later_1.0.0       htmlwidgets_1.5.1 promises_1.1.0    bitops_1.0-6     
## [25] RCurl_1.98-1.1    signal_0.7-6      mime_0.9          evaluate_0.14    
## [29] rmarkdown_1.17    proxy_0.4-23      stringi_1.4.6     compiler_3.6.1   
## [33] jsonlite_1.6      httpuv_1.5.2      fftw_1.0-6

See also

comments powered by Disqus